gen child_tot0 = child_tot
replace child_tot0 = birth_order if parent_i_1040==0
capture gen eitc_unadj =.

capture {
	gen parent_agiz_unadj = parent_agi_unadj
 	replace parent_agiz_unadj = 0 if parent_i_1040==0 & i_obstaxyr==1
}

gen i_eitcany = .
forvalues k=0/3 {
	disp "****Kid: `k'****"
	local k1 = "`k'="
	if `k'==3 local k1="3 <"

	replace eitc_unadj = parent_agiz_unadj*(eitc_inrate`k'/100)  if parent_agiz_unadj<eitc_maxcstart`k' & `k1'= child_tot0
	replace eitc_unadj = eitc_maxc`k'  if inrange(parent_agiz_unadj,eitc_maxcstart`k',eitc_outstart`k')  &`k1'= child_tot0
	replace eitc_unadj = eitc_maxc`k'-(parent_agiz_unadj-eitc_outstart`k')*(eitc_outrate`k'/100)  if inrange(parent_agiz_unadj,eitc_outstart`k',eitc_outend`k')  &`k1'= child_tot0
	replace eitc_unadj = 0 if parent_agiz_unadj>eitc_outend`k' & `k1'= child_tot0
	replace eitc_unadj = 0 if year<=1975
	replace eitc_unadj = . if parent_agiz_unadj==.

	*Calculate potential EITC bump based on income (if kid born before cutoff)
	*egg, made modifcations here since variables are defined at k0 already
	capture gen eitc = .
	replace eitc =eitc_unadj`b'*(cpi_2015/cpi_jan)


	***NEW -- PRIMARY EITC ELIGIBILITY GROUP
	replace i_eitcany = (parent_agiz_unadj<eitc_outend`k') if `k1'= child_tot0
	replace i_eitcany = . if parent_agiz_unadj==.
	replace i_eitcany = 0 if year<=1975

}
